import request from '@/utils/request'

export function getNoticeInfo(
  noticeTitle: string,
  noticeType: string,
  noticeState: string,
  pageSize: number,
  page: number
) {
  return request({
    url:
      '/notice/getInfo?noticeTitle=' +
      noticeTitle +
      '&noticeType=' +
      noticeType +
      '&noticeState=' +
      noticeState +
      '&pageSize=' +
      pageSize +
      '&page=' +
      page,
    method: 'get'
  })
}

export function getAllNotice(noticeState: string) {
  return request({
    url: '/notice/getAllNotice?noticeState=' + noticeState,
    method: 'get'
  })
}

export function deleteNoticeById(noticeId: number) {
  return request({
    url: '/notice/noticeDelete/' + noticeId,
    method: 'delete'
  })
}

export function getNoticeById(noticeId: number) {
  return request({
    url: '/notice/getInfo/' + noticeId,
    method: 'get'
  })
}

export function update(notice: object) {
  return request({
    url: '/notice/updatePublishNotice',
    method: 'put',
    data: notice
  })
}

export function insert(notice: object) {
  return request({
    url: '/notice/publishNotice',
    method: 'post',
    data: notice
  })
}

export function updateState(noticeId: number, noticeState: string) {
  return request({
    url: '/notice/updateState',
    method: 'put',
    data: { noticeId: noticeId, noticeState: noticeState }
  })
}
